<form enctype='multipart/form-data' action='documents.php' method='POST'>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
<?php
// Where the file is going to be placed
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['userfile']['name']);
 
 // Determine file extention
 $oldfile  = basename($_FILES['userfile']['name']);
 $pos   = strpos($oldfile,".",0);
 $ext   = trim(substr($oldfile,$pos+1,strlen($oldfile))," ");
 
 if($ext != 'csv'){ 
  print "<B>fileype should be.csv<B>";
 }
 else {
  $newfile   = "csvlist." . $ext;
  
  $target_path  = "upload/";
  $target_path = $target_path . basename($newfile);
  
  if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
   header("Location: txt_export_script.php");    } 
  else {
   $Errors = $_FILES['userfile']['error'];
   print "$Errortext";
  }
 }
//require('index.php');

?>